package jjn.round1;

/**
 * @author Jjn
 * @since 2022-09-21 8:44
 */
public class LeetCode26_RemoveDuplicatesFromArray {
    
    public int removeDuplicates(int[] nums) {
        if (nums.length <= 1) {
            return nums.length;
        }
        int fast = 1, slow = 0;
        while (fast < nums.length) {
            if (nums[slow] != nums[fast]) {
                slow++;
                nums[slow] = nums[fast];
            }
            fast++;
        }
        return slow + 1;
    }
}
